function getObj(id){
	return document.getElementById(id);	
}
function getBrowserHeight(){
	if (window.innerHeight){
		winHeight = window.innerHeight;
	}else if ((document.body) && (document.body.clientHeight)){
		winHeight = document.body.clientHeight;
	}
	if (document.documentElement && document.documentElement.clientHeight){
		winHeight = document.documentElement.clientHeight;
	}
	return winHeight;
}
function getBrowserWidth(){
	if (window.innerWidth){
		winWidth = window.innerWidth;
	}else if ((document.body) && (document.body.clientWidth)){
		winWidth = document.body.clientWidth;
	}
	if (document.documentElement && document.documentElement.clientWidth){
		winWidth = document.documentElement.clientWidth;
	}
	return winWidth;
}
function creatInput(val,tipe){
	var input=document.createElement("input");
	input.type=tipe;
	input.value=val;
	return input;	
}

function popup(){
	this.bodyHeight=document.body.offsetHeight;
	this.bodyWidth=document.body.offsetWidth;
	this.clientHeight=getBrowserHeight();
	this.clientWidth=getBrowserWidth();
	this.bodyHeight=this.bodyHeight<this.clientHeight?this.clientHeight:this.bodyHeight;
	this.msgWin=getObj("sysMsg");
	this.cover=getObj("cover");
	this.cover.style.height=this.bodyHeight+"px";
	this.cover.style.width=this.bodyWidth+"px";
	this.btnYes=creatInput("确 定","button");
	this.btnCancel=creatInput("取 消","button");
}

popup.prototype={
	alertMsg:function(s,func){
		getObj("msgText").innerHTML=s;
		var m=this;
		this.show();
		this.btnYes.onclick=function(){
			m.closeWin();
			if(func){func(false)};
		}
		getObj("btnCont").appendChild(this.btnYes);
	},
	confirmMsg:function(s,func){
		getObj("msgText").innerHTML=s;
		var m=this;
		this.show();
		this.btnYes.onclick=function(){
			m.closeWin();
			if(func){func(true)};
		}
		this.btnCancel.onclick=function(){
			m.closeWin();
			if(func){func(false)};
		}
		getObj("btnCont").appendChild(this.btnCancel);
		getObj("btnCont").appendChild(this.btnYes);
	},
	show:function(){
		this.cover.appendChild(document.createElement("iframe"));
		this.cover.style.display="block";
		this.msgWin.style.display="block";
		this.msgWin.style.top=(this.clientHeight-this.msgWin.offsetHeight)/2+document.documentElement.scrollTop+"px";
		this.msgWin.style.left=(this.clientWidth-this.msgWin.offsetWidth)/2+document.documentElement.scrollLeft+"px";
	},
	closeWin:function(){
		getObj("msgText").innerHTML="";
		getObj("btnCont").innerHTML="";
		this.cover.innerHTML="";
		this.cover.style.display="none";
		this.msgWin.style.display="none";
	}
}
var Popup=new popup();
window.onresize=function(){
	Popup=new popup();//调整窗口大小时重新计算窗口大小,提供给组件进行定位
}
